package rms.mall.server.domain.context;

import com.alibaba.ttl.TransmittableThreadLocal;
import lombok.Data;

import java.io.Serializable;

@Data
public class CommonContext implements Serializable {

    private static final long serialVersionUID = -3395618317964633994L;

    private static TransmittableThreadLocal<CommonContext> LOCAL = new TransmittableThreadLocal<CommonContext>() {
        @Override
        protected CommonContext initialValue() {
            return new CommonContext();
        }
    };


    private Long acctId;
    

    private String acctName;

    private Integer versionCode;


    public static CommonContext get() {
        return LOCAL.get();
    }

    public static void remove() {
        LOCAL.remove();
    }

    public static CommonContext removeAndSet() {
        remove();
        return set();
    }


    public static CommonContext set() {
        CommonContext ict = CommonContext.get();
        if (ict == null) {
            return null;
        }
        return ict;
    }

}
